Integrating edge costs into each representation.
- Edge List: The most straightforward approach. Simply add the weight as a third element to the tuple, creating a structure like `(u, v, w)`.
- Adjacency List: Instead of storing just the neighbor, store a pair of `(neighbor, weight)`. Alternatively, the value in the dictionary can be another dictionary mapping neighbors to their weights.
- Adjacency Matrix: Store the numeric weight `w` at `A[u, v]` instead of `1`. A special value, such as
0,∞, orNaN, must be chosen to represent the absence of an edge. This choice must be applied consistently.